Task scheduling is one of the core functions of an operating system, and the quality of task scheduling directly affects performance, fairness, timeliness, and the like of program running. For an operating system with only a single processor core, task scheduling only needs to solve an issue of switching among different tasks. However, for an operating system with multiple processor cores, in addition to scheduling switching among different tasks, assignment of multiple tasks to the multiple processor cores and task migration processes among the multiple processor cores need to be processed, so as to ensure load balancing among the multiple processor cores.
In an operating system with multiple processor cores, multiple tasks need to contend for various shared resources, such as a shared cache, a memory controller, and a memory bus. Different tasks have different requirements for resources. If the foregoing resources are not considered during task scheduling performed by a processor, it results that resources of other processor cores are not fully used while a part of resources (such as a shared cache and a shared access memory) are contended for, so as to impose negative effects on performance of an entire system.
In processing of task scheduling in the prior art, during task migration, an operating system selects by default in descending order of priorities, from a tail of a highest priority linked list that includes tasks, tasks allowed to be migrated, but does not analyze a program of a task to be migrated or an effect of task migration on another task in a destination processor core to which the task is migrated. Therefore, performance and service quality of an entire system cannot be ensured. If the task to be migrated is not suitable to run in the destination processor core, the system performance may become extremely bad.